#ifndef VMPRIM_H
#define VMPRIM_H

#include <QString>
#include <QHash>

#include "VMExec.h"

namespace CuteVM {

    class Machine;

    class PrimRunner {
    public:
        virtual ExecResult & exec(Machine *vm);
    };

    class Primitive {
    private:
        QString module;
        QString name;
        int arity;
        PrimRunner & runner;
    public:
        Primitive(QString module, QString name, int arity, PrimRunner & runner);
        int getArity();
        QString getModuleName();
        QString getName();
        PrimRunner & getRunner();
    };


    class PrimManager {
    private:
        QHash<QString,Primitive> primitives;
    public:
        PrimManager() {
            primitives = QHash<QString,Primitive>();
        }

        bool installPrimitive(Primitive prim);
        Primitive fetchPrimitive(QString module, QString prim);

    };


} // namespace CuteVM

#endif // VMPRIM_H
